Apple II
File Type Notes
_____________________________________________________________________________
                                                  Developer Technical Support


File Type:         $1B (27)
Auxiliary Type:    All

Full Name:     AppleWorks Spreadsheet File
Short Name:    AppleWorks SS File

Revised by:    Bob Lissner                                      November 1988
Written by:    Bob Lissner                                      February 1984

Files of this type and auxiliary type contain an AppleWorks(TM) Spreadsheet 
file.
_____________________________________________________________________________

Files of type $1B and any auxiliary type contain an AppleWorks Spreadsheet 
file.  AppleWorks is now published by CLARIS.  For information on AppleWorks, 
contact CLARIS at:

                    CLARIS
                    440 Clyde Avenue
                    Mountain View, CA 94043

                    Technical Information
                    Telephone:  (415) 962-0371
                    AppleLink:  Claris.Tech

                    Non-Technical Information
                    Telephone:  (415) 962-8946
                    AppleLink:  Claris.CR

In addition to the support available from CLARIS, Bob Lissner, the author of 
AppleWorks, maintains a bulletin board for AppleWorks-related information.  
You can obtain technical information and file formats from this system as well 
as submit your comments in writing.  You can reach this system at (702) 831-
1722.


Definitions

The following definitions apply to AppleWorks files in addition to those 
defined for all Apple II file types:

    MRL    Data base multiple record layout
    SRL    Data base single record layout
    RAC    Review/Add/Change screen
    DB     AppleWorks or /// E-Z Pieces Data Base
    SS     AppleWorks or /// E-Z Pieces Spreadsheet
    WP     AppleWorks or /// E-Z Pieces Word Processor
    AW     AppleWorks or /// E-Z Pieces


Auxiliary Type Definitions

The volume or subdirectory auxiliary type word for this file type is defined 
to control uppercase and lowercase display of filenames.  The highest bit of 
the least significant byte corresponds to the first character of the filename, 
the next highest bit of the least significant byte corresponds to the second 
character, etc., through the second bit of the most significant byte, which 
corresponds to the fifteenth character of the filename.

AppleWorks performs the following steps when it saves a file to disk:

1.    Zeros all 16 bits of the auxiliary type word.
2.    Examines the filename for lowercase letters.  If one is found, it 
      changes the corresponding bit in the auxiliary type word to 1 and 
      changes the letter to uppercase.
3.    Examines the filename for spaces.  If one is found, it changes the 
      corresponding bit in the auxiliary type word to 1 and changes the 
      space to a period.

When files are read from disk, the filename and auxiliary type information 
from the directory file entry are used to determine which characters should be 
lowercase and which periods should be displayed as spaces.  If you use the 
auxiliary type bytes for a different purpose, AppleWorks will still display 
the filenames, but the wrong letters are likely lowercase.


Spreadsheet Files

Spreadsheet files start with a 300 byte header record that contains basic 
information about the file, including column widths, printer options, window 
definitions, and standard values.

Header Record

The spreadsheet header record contains the following entries:

+000 to +003                Skip 4 bytes.
+004 to +130       Bytes    The column width for each column.
+131               Byte     Order of recalculation.  ASCII R or 
                            C.
+132               Byte     Frequency of recalculation.  ASCII A 
                            or M.
+133 to +134       Word     Last row referenced.
+135               Byte     Last column referenced.
+136               Byte     Number of windows:  ASCII 1:  just 
                            one window, S: side by side windows, 
                            T: top and bottom windows.
+137               Byte     Boolean:  If there are two windows, 
                            are they synchronized?
+138 to +161                The next 20 (approximately) 
                            variables are for the current 
                            window.  If there is only one 
                            window, it is the current window.  
                            If there are two windows, the 
                            current window is the window that 
                            had the cursor in it.
+138               Byte     Window standard format for label 
                            cells.  2: left justified, 3: right 
                            justified, 4: centered.
+139               Byte     Window standard format for value 
                            cells.  2: fixed, 3: dollars, 4: 
                            commas, 5: percent, 6: appropriate
+140               Byte     More of window standard format for 
                            value cells.  Number of decimal 
                            places to display.  Values from 0 to 
                            7.
+141               Byte     Top screen line used by this window.  
                            This is the line that the 
                            =====A=========B==== appears on.  
                            Normally 1 unless there are top and 
                            bottom windows.
+142               Byte     Leftmost screen column used by this 
                            window.  This is the column that the 
                            hundreds digit of the row number 
                            appears in.  Normally 0 unless there 
                            are side-by-side windows.
+143 to +144       Word     Top, or first, row appearing in 
                            titles area.  This will probably be 
                            0 if there are no top titles.
+145               Byte     Leftmost, or first, column appearing 
                            in left titles area.  This will 
                            probably be 0 if there are no left 
                            titles.
+146 to +147       Word     Last row appearing in top titles 
                            area.  This will probably be zero if 
                            there are no top titles.
+148               Byte     Last column appearing in left titles 
                            area. This will probably be zero if 
                            there are no left titles.
+149 to +150       Word     Top, or first, row appearing in the 
                            body of the window.  The body is 
                            defined as those rows that are on 
                            the screen, but not in the titles 
                            area.
+151               Byte     Leftmost, or first, column appearing 
                            in the body of the window.
+152               Byte     The screen line that the top body 
                            row goes on.  Normally 2, unless 
                            there are top titles or top and 
                            bottom windows.
+153               Byte     Leftmost screen column used for the 
                            leftmost body column.  Normally 4 
                            unless there are side titles, or 
                            side-by-side windows.
+154 to +155       Word     Bottom, or last, row appearing in 
                            this window.
+156               Byte     Rightmost, or last, column appearing 
                            in this window.
+157               Byte     The screen line that the last body 
                            row goes on.  Normally $13 (19) 
                            unless there are top and bottom 
                            windows.
+158               Byte     The rightmost screen column used by 
                            this window.  Normally $4E (78) 
                            unless there are side-by-side 
                            windows.
+159               Byte     Number of horizontal screen 
                            locations used to display the body 
                            columns.  Normally $48 (72), because 
                            8 columns of 9 characters each are 
                            the standard display.  This is 
                            affected by side-by-side windows, 
                            side titles, and variable column 
                            widths.
+160               Byte     Boolean:  Rightmost column is not 
                            fully displayed.  This can only 
                            happen when the body portion of the 
                            window is narrower than the width of 
                            a particular column.
+161               Flag     Titles switch for this window.  Bit 
                   Byte     7:  top titles, Bit 6:  side titles.  
                            These bits represent top titles, 
                            side titles, both, and no titles.
+162 to +185                Window information for the second 
                            window.  This is meaningful only if 
                            there are two windows.  This is the 
                            information for the window that the 
                            cursor is not currently in.  See the 
                            descriptions for the current window 
                            (+138 to +161).
+186 to +212                Not currently used.
+213               Byte     Boolean:  Cell protection is on or 
                            off.
+214                        Not currently used.
+215               Byte     Platen width value, in 10ths of an 
                            inch.  For example, a value of 80 
                            inches entered by the user will show 
                            as 80 or $50.
+216               Byte     Left margin value.  All inches 
                            values are in 10ths of an inch.
+217               Byte     Right margin value.
+218               Byte     Characters per inch.
+219               Byte     Paper length value, in 10ths of an 
                            inch.
+220               Byte     Top margin value.
+221               Byte     Bottom margin value.
+222               Byte     Lines per inch.  6 or 8.
+223               Byte     Spacing:  S(ingle, D(ouble, or 
                            T(riple.  Expect these three 
                            letters, even in European versions.
+224 to +237       Bytes    If user has specified "Send special 
                            codes to printer," this is a 13-byte 
                            string containing those codes.
+238               Byte     Boolean:  Print a dash when an entry 
                            is blank.
+239               Byte     Boolean:  Print report header.
+240               Byte     Boolean:  Zoomed to show formulas.
+241 to +249                Reserved for future use.
+250 to +299                Available.  Will never be used by 
                            AppleWorks.  If you are creating 
                            these files, you can use this area 
                            to keep information that is 
                            important to your program.

Row Records

Row records contain a variable amount of information about each row that is 
non-blank.  Each row record contains enough information to completely build 
one row of the spreadsheet:

+000 to +001       Word     Number of additional bytes to read 
                            from disk.  $FFFF means end of file.
+002 to +003       Word     Row number.
+004               Byte     Beginning of actual information for 
                            the row.  This byte of each record 
                            will always be a control byte.  
                            Other control bytes within each 
                            record define the contents of the 
                            record.  Control bytes may be:

                            $01-$7F    This is a count of the 
                                       number of following 
                                       bytes that are the 
                                       contents of a cell 
                                       entry.
                            $81-$FE    This (minus $80) is a 
                                       count of the number of 
                                       columns to be skipped.  
                                       For example, $82 means 
                                       skip two columns.
                            $FF        This indicates the end 
                                       of the row.

Cell Entries

Cell entries contain all the information that is necessary to build one cell.  
There are several types:

Value constants are cells that have a value that cannot change.  This means 
that someone typed a constant into the cell, 3.14159, for example.

+000               Flag     Bit 7 is always on.
                   Byte     Bit 6 on means that if the value is zero, 
                            display a blank instead of a zero.  This 
                            is for pre-formatted cells that still have 
                            no value.
                            Bit 5 is always on.
                            Bit 4 on means that labels cannot be typed 
                            into this cell.
                            Bit 3 on means that values cannot be typed 
                            into this cell.
                            Bits 2,1, and 0 specify the formatting for 
                            this cell:

                                 1    Use spreadsheet standard
                                 2    Fixed
                                 3    Dollars
                                 4    Commas
                                 5    Percent
                                 6    Appropriate

+001               Flag     Bit 7 is always zero.
                   Byte     Bit 6 is always zero.
                            Bit 5 is always zero.
                            Bit 4 on indicates that this cell must be 
                            calculated the next time this spreadsheet 
                            is calculated, even if none of the 
                            referenced cells are changed.  This bit 
                            makes sense on for cells that have a 
                            calculated formula.
                            Bits 2, 1, and 0:  Number of decimal 
                            places for fixed, dollars, commas, or 
                            percent formats.
+002 to +009                8-byte SANE double format floating point 
                            number.

Value Formulas

Value formulas are cells that contain information that has to be evaluated.  
Formulas like AA17+@sum(r19...r21) and @Error are examples.  Specific format:

+000               Flag     Bit 7 is always on.
                   Byte     Bit 6 on means to not display the cell.  
                            This was originally intended for pre-
                            formatted cells that still have no value.  
                            If a value is placed in this cell, be sure 
                            to turn off this bit.
                            Bit 5 is always off.
                            Bits 4, 3, 2, 1, and 0 are the same as 
                            value constants.
+001                        Bit 7 is always on.
                            Bit 6 on indicates that the last 
                            evaluation of this formula resulted in an 
                            @NA.
                            Bit 5 on indicates that the last 
                            evaluation of this formula resulted in an 
                            @Error.
                            Bits 4, 2, 1, and 0 are the same as value 
                            constants.
+002 to +009                8-byte SANE double floating point number 
                            that is the most recent evaluation of this 
                            cell.
+010 to nnn                 Various control bytes that are tokens 
                            representing the formula that was entered 
                            by the user.  They are:

                            Byte   Means
                            $D9    @Round
                            $DA    @Or
                            $DB    @And
                            $DC    @Sum
                            $DD    @Avg
                            $DE    @Choose
                            $DF    @Count
                            $E0    @Error (followed by 3 bytes of zero)
                            $E1    Reserved for future @IRR
                            $E2    @If
                            $E3    @Int
                            $E4    @Lookup
                            $E5    @Max
                            $E6    @Min
                            $E7    @NA (followed by three bytes of zero)
                            $E8    @NPV
                            $E9    @Sqrt
                            $EA    @Abs
                            $EB    Not currently used
                            $EC    Not equal (<>)
                            $ED    greater than or equal to (>=)
                            $EE    less than or equal to (<=)
                            $EF    equals (=)
                            $F0    greater than (>)
                            $F1    less than (<)
                            $F2    comma (,)
                            $F3    exponentiation sign (^)
                            $F4    right parenthesis (")")
                            $F5    minus (-)
                            $F6    plus (+)
                            $F7    divide (/)
                            $F8    multiply (*)
                            $F9    left parenthesis ("(")
                            $FA    unary minus (-) i.e., -A3
                            $FB    (unary plus (+) i.e., +A3)
                            $FC    ellipses (...)
                            $FD    Next 8 bytes are SANE double number
                            $FE    Next 3 bytes are row, column reference

Two of the codes require special information.  Code $FD indicates that the 
next 8 bytes are a SANE numerics package double precision floating point 
number.  All constants within formulas are carried in this manner.

Code $FE indicates that the next three bytes point at a cell:

+000               Byte     $FE
+001               Byte     Column reference.  Add this byte to the 
                            column number of the current cell to get 
                            the column number of the pointed at cell.  
                            This value is sometimes negative, but Add 
                            always works.
+002 to +003       Word     Row reference.  Add this word to the row 
                            number of the current cell to get the row 
                            number of the pointed at cell.  This value 
                            is sometimes negative, but Add always 
                            works.

Propagated Label Cells

Propagated label cells are labels that place one particular ASCII character in 
each position of a window.  Handy for visual effects like underlining.

+8192 to +16383    Bytes    Portion of double high-resolution 
+000               Flag     Bit 7 is always zero.
                   Byte     Bit 6 is meaningless.
                            Bit 5 is always on.
                            Bit 4 and bit 3 are protection, just like 
                            value cells.
                            Bits 2, 1, and 0 are meaningless.  Put a 1 
                            here.
+001               Byte     This is the actual character that is to be 
                            put in each position in the cell.

Regular Label Cells

Regular label cells contain alphanumeric information, such as headings, names, 
and other descriptive information that is not the basis for calculations.

+000               Flag     Bits 7, 6, and 5 are always zero.
                   Byte     Bits 4 and 3 are same as value cells.
                            Bits 2, 1, and 0 determine cell 
                            formatting:
                            01    Use spreadsheet standard formatting
                            02    Left justify
                            03    Right justify
                            04    Center
+001 to +nnn       Bytes    ASCII characters that actually display.  
                            The actual length was defined earlier in 
                            the word that contained the actual number 
                            of bytes to read from disk.

